package it.polimi.traveldream.ejbclient.dtos;

import java.io.Serializable;
import java.sql.Timestamp;
import javax.validation.constraints.Min;

public class ParticipationDTO implements Serializable {
	private static final long serialVersionUID = 2801937377824286216L;
	private int reservations;
	private Timestamp timestamp;
	private TravelPackageDTO travelpackage;
	private UserDTO user;
	
	public ParticipationDTO() {
		super();
	}

	public ParticipationDTO(int reservations, Timestamp timestamp,
			TravelPackageDTO travelpackage, UserDTO user) {
		super();
		this.reservations = reservations;
		this.timestamp = timestamp;
		this.travelpackage = travelpackage;
		this.user = user;
	}


	@Min(value = 0, message = "Invalid number of reservations")
	public int getReservations() {
		return reservations;
	}

	public void setReservations(int reservations) {
		this.reservations = reservations;
	}

	public Timestamp getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Timestamp timestamp) {
		this.timestamp = timestamp;
	}

	public TravelPackageDTO getTravelpackage() {
		return travelpackage;
	}

	public void setTravelpackage(TravelPackageDTO travelpackage) {
		this.travelpackage = travelpackage;
	}

	public UserDTO getUser() {
		return user;
	}

	public void setUser(UserDTO user) {
		this.user = user;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((travelpackage == null) ? 0 : travelpackage.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ParticipationDTO other = (ParticipationDTO) obj;
		if (travelpackage == null) {
			if (other.travelpackage != null)
				return false;
		} else if (!travelpackage.equals(other.travelpackage))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}
	
}
